package cn.samir.sudoku.adapter;

import cn.samir.sudoku.R;
import cn.samir.sudoku.share.ShareItem;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

public class ShareGridViewAdapter extends AdapterBase<ShareItem> {

	Context context;

	public ShareGridViewAdapter(Context context) {
		this.context = context;
	}

	@Override
	protected View getExView(int position, View convertView, ViewGroup parent) {
		ViewHolder view = null;
		if (convertView == null) {
			convertView = View.inflate(context, R.layout.item_share, null);
			view = new ViewHolder();
			view.iv = (ImageView) convertView.findViewById(R.id.iv_shareres);
			view.tv = (TextView) convertView.findViewById(R.id.tv_sharetext);
			convertView.setTag(view);
		} else {
			view = (ViewHolder) convertView.getTag();
		}
		ShareItem item = (ShareItem) getItem(position);
		view.iv.setImageResource(item.resId);
		view.tv.setText(item.name);
		return convertView;
	}

	@Override
	protected void onReachBottom() {

	}

	class ViewHolder {
		public ImageView iv;
		public TextView tv;
	}

}
